//编程求出10以内的所有数的阶乘的倒数和。
#include <stdio.h>

struct frac//分数类
{
    long long num,den;
};

long long gcd(long long a,long long b)//最大公约数
{
    return b==0?a:gcd(b,a%b);
}

struct frac reduction(struct frac f)//约分
{
    long long g=gcd(f.den,f.num);
    f.den/=g;
    f.num/=g;
    return f;
}

struct frac plus(struct frac lhs,struct frac rhs)//分数加法
{
    long long d=rhs.den*lhs.den;
    long long n=rhs.num*lhs.den+lhs.num*rhs.den;
    lhs.den=d;
    lhs.num=n;
    return lhs;
}

int main()
{
    long long f = 1;
    struct frac s = {1,1};
    for(int i=1;i<=10;i++)
    {
         f *= i;
         struct frac r = {1,f};;
         s = plus(s,r);
         s = reduction(s);
    }
    printf("sum(1/n!)(n>=0&&n<=10) = %I64d/%I64d\n",s.num,s.den);
    return 0;
}